package com.mbmed.doctor.lab1.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.lab1.bo.Lab1Bo;
import com.mbmed.doctor.lab1.mapper.InspectListBean;
import com.mbmed.doctor.lab1.mapper.Lab1;
import com.mbmed.doctor.lab1.mapper.InspectBean;
import com.mbmed.doctor.lab1.mapper.InspectDetailBean;

/**
 * @file  Lab1Service.java
 * @author jiangcangpeng
 * @version 0.1
 * @todo	Lab1服务操作接口
 * Copyright(C), 2013-2014
 *		 Shenzhen Coordinates Software Development Co., Ltd.
 * History
 *   	1. Date: 2014-11-06 02:14:23
 *      	Author: jiangcangpeng
 *      	Modification: this file was created
 *   	2. ...
 */
@Path("/lab1")
@Component
public class Lab1Service {
	
	private static Logger logger = Logger.getLogger(Lab1.class);
	
	@Autowired
	private Lab1Bo lab1Bo;
	
	@Context
	Request request;

	
	/**
	 * 查找所有数据库记录
     * @return type : List 返回查询操作所有符合条件的记录的VO对象集合，操作失败返回null
     */
	@GET
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public List<Lab1> getAll() throws Exception{
        List<Lab1> list = new ArrayList<Lab1>();
        return lab1Bo.getAll();        
    }
	
	/**
	 * 3-4
	* @Title: queryPatientInspectDetailByVaa01
	* @Description: TODO(这里用一句话描述这个方法的作用)
	* @param vaa01
	* @return
	* @throws Exception
	* @return List<Lab1BeanDetail>    返回类型
	* @throws
	 */
	@GET
	@Path("/inspectDetailByVaa01")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
	public List<InspectDetailBean> queryPatientInspectDetailByVaa01(
			@QueryParam("vaa01") java.lang.Integer vaa01) throws Exception{
		List<InspectDetailBean> list = new ArrayList<InspectDetailBean>();
		list = lab1Bo.queryPatientInspectDetailByVaa01(vaa01);
		if(list.size()>0){
			return list;
		}
		return list;
	}
	
	@GET
	@Path("/inspectListByvaa04")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
	public List<InspectListBean> inspectListByvaa04(
			@QueryParam("vaa04") java.lang.String vaa04) throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("vaa04", vaa04);
		
		//List<InspectListBean> list = new ArrayList<InspectListBean>();
		List list = lab1Bo.inspectListByvaa04(map);
		if(list.size()>0){
			return list;
		}
		return list;
	}
	
	@GET
	@Path("/inspectListByvaa01")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
	public List<InspectListBean> inspectListByvaa01(
			@QueryParam("vaa01") java.lang.String vaa01) throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("vaa01", vaa01);
		return lab1Bo.inspectListByvaa01(map);
	}
	
	@GET
	@Path("/inspectDetailInfoByLab01")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
	public List<InspectDetailBean> inspectDetailInfoByLab01(
			@QueryParam("lab01") java.lang.Integer lab01) throws Exception{
		return lab1Bo.inspectDetailInfoByLab01(lab01);
	}
	
	
	
	
	@GET
	@Path("/inspectDetailBylab01")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
	public List<InspectDetailBean> inspectDetailBylab01(
			@QueryParam("lab01") java.lang.Integer lab01) throws Exception{
		List<InspectDetailBean> list = new ArrayList<InspectDetailBean>();
		list = lab1Bo.inspectDetailBylab01(lab01);
		if(list.size()>0){
			return list;
		}
		return list;
	}
	
    /**
     * 查找符合条件的所有数据库记录
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("{id}")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public Lab1 getLab1(@PathParam("id") String id) throws Exception{
    	Lab1 lab1 = null;
    	return lab1Bo.get(id);        
    }
    /**
     * 向数据库中插入一条记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : 返回插入操作是否成功
     * @throws Exception
     */
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	public Lab1 saveLab1(
			@FormParam("lab01") java.lang.Integer lab01,
			@FormParam("lab02") java.lang.String lab02,
			@FormParam("vaa01") java.lang.Integer vaa01,
			@FormParam("vaa07") java.lang.Integer vaa07,
			@FormParam("vap01") java.lang.Integer vap01,
			@FormParam("bck01a") java.lang.Integer bck01a,
			@FormParam("abbrp") java.lang.String abbrp,
			@FormParam("abbrw") java.lang.String abbrw,
			@FormParam("lab09") java.lang.String lab09,
			@FormParam("vaa05") java.lang.String vaa05,
			@FormParam("abw01") java.lang.String abw01,
			@FormParam("lab12") java.lang.Integer lab12,
			@FormParam("aau01") java.lang.String aau01,
			@FormParam("lab14") java.util.Date lab14,
			@FormParam("bdp02") java.lang.String bdp02,
			@FormParam("lab16") java.lang.String lab16,
			@FormParam("bes02") java.lang.String bes02,
			@FormParam("lab18") java.lang.String lab18,
			@FormParam("acf01") java.lang.Integer acf01,
			@FormParam("lab20") java.util.Date lab20,
			@FormParam("lab21") java.lang.Byte lab21,
			@FormParam("lab22") java.lang.String lab22,
			@FormParam("lab23") java.lang.String lab23,
			@FormParam("abb02") java.lang.String abb02,
			@FormParam("bey01a") java.lang.Integer bey01a,
			@FormParam("bey01b") java.lang.Integer bey01b,
			@FormParam("bew02") java.lang.String bew02,
			@FormParam("bck01b") java.lang.Integer bck01b,
			@FormParam("bey07") java.lang.Byte bey07,
			@FormParam("lab30") java.lang.Integer lab30,
			@FormParam("lab31") java.lang.Integer lab31,
			@FormParam("lab32") java.lang.Byte lab32,
			@FormParam("lab33") java.lang.Byte lab33,
			@FormParam("lab34") java.util.Date lab34,
			@FormParam("lab35") java.util.Date lab35,
			@FormParam("lab36") java.lang.Integer lab36,
			@FormParam("lab37") java.lang.Byte lab37,
			@FormParam("bce03") java.lang.String bce03,
			@FormParam("bck01c") java.lang.Integer bck01c,
			@FormParam("lab40") java.util.Date lab40,
			@FormParam("vaf01") java.lang.Integer vaf01,
			@FormParam("lab42") java.lang.String lab42,
			@FormParam("lab43") java.util.Date lab43,
			@FormParam("bce03a") java.lang.String bce03a,
			@FormParam("bce03c") java.lang.String bce03c,
			@FormParam("lab46") java.util.Date lab46,
			@FormParam("bce01d") java.lang.Integer bce01d,
			@FormParam("bce03d") java.lang.String bce03d,
			@FormParam("bce03e") java.lang.String bce03e,
			@FormParam("lab50") java.util.Date lab50,
			@FormParam("bce01b") java.lang.Integer bce01b,
			@FormParam("bce03b") java.lang.String bce03b,
			@FormParam("lab53") java.util.Date lab53,
			@FormParam("lab54") java.lang.String lab54,
			@FormParam("lab55") java.math.BigDecimal lab55,
			@FormParam("lab56") java.lang.String lab56,
			@FormParam("bet02") java.lang.String bet02,
			@FormParam("lab58") java.lang.String lab58,
			@FormParam("lab59") java.lang.Byte lab59,
			@FormParam("lab60") java.util.Date lab60,
			@FormParam("lab61") java.util.Date lab61,
			@FormParam("lab62") java.lang.String lab62,
			@FormParam("lab63") java.lang.String lab63,
			@FormParam("lab64") java.lang.String lab64,
			@FormParam("bex02") java.lang.String bex02,
			@FormParam("bck01d") java.lang.Integer bck01d,
			@FormParam("baq03") java.lang.String baq03,
			@FormParam("lab01a") java.lang.Integer lab01a,
			@FormParam("lab69") java.lang.String lab69,
			@Context HttpServletResponse servletResponse
	) throws Exception {
		Lab1 lab1 = new Lab1();
		lab1.setLab01(lab01);
		lab1.setLab02(lab02);
		lab1.setVaa01(vaa01);
		lab1.setVaa07(vaa07);
		lab1.setVap01(vap01);
		lab1.setBck01a(bck01a);
		lab1.setAbbrp(abbrp);
		lab1.setAbbrw(abbrw);
		lab1.setLab09(lab09);
		lab1.setVaa05(vaa05);
		lab1.setAbw01(abw01);
		lab1.setLab12(lab12);
		lab1.setAau01(aau01);
		lab1.setLab14(lab14);
		lab1.setBdp02(bdp02);
		lab1.setLab16(lab16);
		lab1.setBes02(bes02);
		lab1.setLab18(lab18);
		lab1.setAcf01(acf01);
		lab1.setLab20(lab20);
		lab1.setLab21(lab21);
		lab1.setLab22(lab22);
		lab1.setLab23(lab23);
		lab1.setAbb02(abb02);
		lab1.setBey01a(bey01a);
		lab1.setBey01b(bey01b);
		lab1.setBew02(bew02);
		lab1.setBck01b(bck01b);
		lab1.setBey07(bey07);
		lab1.setLab30(lab30);
		lab1.setLab31(lab31);
		lab1.setLab32(lab32);
		lab1.setLab33(lab33);
		lab1.setLab34(lab34);
		lab1.setLab35(lab35);
		lab1.setLab36(lab36);
		lab1.setLab37(lab37);
		lab1.setBce03(bce03);
		lab1.setBck01c(bck01c);
		lab1.setLab40(lab40);
		lab1.setVaf01(vaf01);
		lab1.setLab42(lab42);
		lab1.setLab43(lab43);
		lab1.setBce03a(bce03a);
		lab1.setBce03c(bce03c);
		lab1.setLab46(lab46);
		lab1.setBce01d(bce01d);
		lab1.setBce03d(bce03d);
		lab1.setBce03e(bce03e);
		lab1.setLab50(lab50);
		lab1.setBce01b(bce01b);
		lab1.setBce03b(bce03b);
		lab1.setLab53(lab53);
		lab1.setLab54(lab54);
		lab1.setLab55(lab55);
		lab1.setLab56(lab56);
		lab1.setBet02(bet02);
		lab1.setLab58(lab58);
		lab1.setLab59(lab59);
		lab1.setLab60(lab60);
		lab1.setLab61(lab61);
		lab1.setLab62(lab62);
		lab1.setLab63(lab63);
		lab1.setLab64(lab64);
		lab1.setBex02(bex02);
		lab1.setBck01d(bck01d);
		lab1.setBaq03(baq03);
		lab1.setLab01a(lab01a);
		lab1.setLab69(lab69);

		return lab1 = lab1Bo.save(lab1);

	}
	/**
     * 删除数据库中与传入的值对象对应的记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : boolean 返回删除操作是否成功
     * @throws Exception
     */
	@DELETE
	@Path("{id}")
	public boolean removeLab1(@PathParam("id") String id) throws Exception{
		if(id == null) return false;
    	return lab1Bo.remove(id);

	}
	
}
